/**
 * 
 */
package com.scpii.universal.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.PropertyConfigurator;

/**
 * UniversalApi
 * 
 * @author 甘建新 2012-10-12下午05:09:55
 */
public class LoggerServlet extends HttpServlet {

	public LoggerServlet() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}

	public void init() throws ServletException {
		// 通过web.xml来动态取得配置文件
		String prefix = getServletContext().getRealPath("/");
		String file = getInitParameter("log4j");
		// 如果没有给出相应的配置文件，则不进行初始化
		if (file != null) {
			PropertyConfigurator.configure(prefix + file);
		}
	}
}
